<?php
namespace App\Modules\Fund;
use App\Modules\AdapterApi;
use App\Services\Fund\FundIndex;
/**
 * Created by PhpStorm.
 * User: 97606
 * Date: 2018/6/12
 * Time: 10:10
 */
class CurrencyAccount extends AdapterApi
{
     /*兑换钱*/
    public function exchange(): array 
    {
        $data = pick_array($this->postData, ['exchange','money','currency_scale','token']);
        return FundIndex::CurrencyAccount()->exchange($data);
    }
    # 充值 系统->a
    public function prepaid(): array
    {
        $data = pick_array($this->postData, ['user_id','currency','user_info','token','opposite_info','remark']);
        return FundIndex::CurrencyAccount()->prepaid($data);


       /* $data = $this->haveIssetReceiveData(['user_id'=>'0', 'currency'=>'0', 'token'=>' ', 'user_info'=>'{}', 'opposite_info'=>'{}', 'remark'=>'']);
        $data['update_ip'] = request()->ip();
        if(\SYSTEM_ID == $data['user_id']){
            return \verify_err($data, '不能为系统用户充值');
        }
        return $this->stepRun($data, 'serverfund/currency/CurrencyAccount/prepaid', 'prepaid', 'prepaid');*/
    }
    # 冻结 a
    public function freeze(): array
    {
        $data = pick_array($this->postData, ['user_id','currency','user_info','token','opposite_info','remark']);
        return FundIndex::CurrencyAccount()->prepaid($data);

        
        $data = $this->haveIssetReceiveData(['user_id'=>'0', 'currency'=>'0', 'token'=>' ', 'reason'=>' ']);
        return $this->stepRun($data, 'serveruser/user/User/infoByIds,serveruser/auth/App/find,serverfund/currency/CurrencyAccount/adminFreeze', '', 'freeze');
    }
    # 解冻 a
    public function unfreeze(): array
    {
        $data = $this->haveIssetReceiveData(['user_id'=>'0', 'currency'=>'0', 'obj_id'=>'0', 'token'=>' ', 'remark'=>'']);
        return $this->stepRun($data, 'serveruser/auth/Token/hGetAll,serveruser/auth/App/find,serverfund/currency/CurrencyAccount/unfreeze', '', 'unfreeze');

    }
    // 获取列表
    public function list(): array
    {
        $data = pick_array($this->postData, ['keywords','token','list_rows','page']);
        return FundIndex::CurrencyAccount()->list($data);
    }
    // 某user_ids的用户资金列表
    public function listByUserIds(): array
    {
         $data = pick_array($this->postData, ['user_ids','token','list_rows','page']);
        return FundIndex::CurrencyAccount()->listByUserIds($data);
    }

}